package com.hexus.eve.entities;

import java.util.Locale;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="chrRaces")

public class Race implements Translatable{
		private static final String DB_TABLE_NAME = "dbo.chrRaces";
		private static final String NAME_COLUMN = "raceName";
		private static final String DESCRIPTION_COLUMN = "description";
		private static final String SHORT_DESCRIPTION_COLUMN = "shortDescription";
		
		@Id	
		@Column(name="raceID")
		private Integer id;
		
		@Column(name="raceName")
		private String name;

		private String description;
		@ManyToOne
		@JoinColumn(name="iconID")
		private Icon icon;

		private String shortDescription;
		
		public Integer getId() {
			return id;
		}
		public void setId(Integer id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getDescription() {
			return description;
		}
		public void setDescription(String description) {
			this.description = description;
		}

		public String getShortDescription() {
			return shortDescription;
		}
		public void setShortDescription(String shortDescription) {
			this.shortDescription = shortDescription;
		}
		
		public Icon getIcon() {
			return icon;
		}
		public void setIcon(Icon icon) {
			this.icon = icon;
		}
		@Override
		public String getTableName() {
			return DB_TABLE_NAME;
		}
		
		@Override
		public void translate(Map<String, String> translationValues, Locale locale) {
			if(translationValues.containsKey(NAME_COLUMN)) {
				setName(translationValues.get(NAME_COLUMN));
			}	
			if(translationValues.containsKey(DESCRIPTION_COLUMN)) {
				setDescription(translationValues.get(DESCRIPTION_COLUMN));
			}
			if(translationValues.containsKey(SHORT_DESCRIPTION_COLUMN)) {
				setShortDescription(translationValues.get(SHORT_DESCRIPTION_COLUMN));
			}
		}
}
